{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "loose-novel",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import json\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "numerous-taste",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(\"../轿车_top_2020.csv\",usecols=[\"series\",\"officePrice\",\"salesSum\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "corporate-hopkins",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       9.98-14.49万\n",
       "1      11.99-12.59万\n",
       "2       9.99-15.89万\n",
       "3      10.98-15.98万\n",
       "4        2.88-4.86万\n",
       "           ...     \n",
       "187    21.57-22.77万\n",
       "188            暂无报价\n",
       "189    22.28-23.98万\n",
       "190     4.89-15.18万\n",
       "191            暂无报价\n",
       "Name: officePrice, Length: 192, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['officePrice']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "sorted-confidence",
   "metadata": {},
   "outputs": [],
   "source": [
    "list = []\n",
    "i = 0\n",
    "for price in data['officePrice']:\n",
    "    \n",
    "    p = price.split(\"-\")\n",
    "    if len(p)<2:\n",
    "        if price == \"暂无报价\":\n",
    "            result = 0\n",
    "        else:\n",
    "            result = float(price.replace(\"万\",\"\"))\n",
    "            list.append(result)\n",
    "    else:              \n",
    "        result = (float(p[0])+float(p[1].replace(\"万\",\"\")))/2\n",
    "        list.append(result)\n",
    "    \n",
    "#     print(price,round(result, 2))\n",
    "    data.loc[:]['officePrice'][i]=result\n",
    "    i = i+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "surgical-symbol",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>series</th>\n",
       "      <th>officePrice</th>\n",
       "      <th>salesSum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>轩逸</td>\n",
       "      <td>12.235</td>\n",
       "      <td>538680</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>英朗</td>\n",
       "      <td>12.290</td>\n",
       "      <td>295857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>朗逸</td>\n",
       "      <td>12.940</td>\n",
       "      <td>417332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>卡罗拉</td>\n",
       "      <td>13.480</td>\n",
       "      <td>343418</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>宏光MINIEV</td>\n",
       "      <td>3.870</td>\n",
       "      <td>119255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187</th>\n",
       "      <td>标致508L新能源</td>\n",
       "      <td>22.170</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>188</th>\n",
       "      <td>标致308</td>\n",
       "      <td>0</td>\n",
       "      <td>370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>189</th>\n",
       "      <td>起亚K5新能源</td>\n",
       "      <td>23.130</td>\n",
       "      <td>427</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>190</th>\n",
       "      <td>景逸S50</td>\n",
       "      <td>10.035</td>\n",
       "      <td>432</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191</th>\n",
       "      <td>传祺GA5</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>192 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        series officePrice  salesSum\n",
       "0           轩逸      12.235    538680\n",
       "1           英朗      12.290    295857\n",
       "2           朗逸      12.940    417332\n",
       "3          卡罗拉      13.480    343418\n",
       "4     宏光MINIEV       3.870    119255\n",
       "..         ...         ...       ...\n",
       "187  标致508L新能源      22.170        17\n",
       "188      标致308           0       370\n",
       "189    起亚K5新能源      23.130       427\n",
       "190      景逸S50      10.035       432\n",
       "191      传祺GA5           0         5\n",
       "\n",
       "[192 rows x 3 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ahead-cylinder",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x20718b13860>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD4CAYAAAAZ1BptAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhVklEQVR4nO3dfYxc1Znn8e/jdhOavNBAPAi37TU78RrBeMGhBZ4lfwRng52QYA+JCCxZrBGKV0pGytt6pj1CgrwJR1YmmUhZdtiAQpY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lL0eQQFiZx9wIow4uI04HpgZ4vzVG87gU3h8SbgkRbmpSqhLfsu4Bl3/7u8lzr63MxsUahBYGZ9wPvJ9rfsAT4aNuu48wJw963uvsTdl5P9Xu129xtJwbmZ2VvN7O25x8BVwC/o8M9jIc24Dszsg2TbTnuAu939K63NUfXM7D7gvWSXLf4dcCswDDwALCO7lPp17l7Yud3WzOw9wP8GDvLH9u2/Jdsv0bHnZmb/lmwHZw/ZgtsD7v5FM/vXZEvfZwNjwMfd/Y3W5bQ2obnpP7v7h9JwbuEcHg5PFwL/6O5fMbNz6ODPYyEFCRERiVJzk4iIRClIiIhIlIKEiIhEKUiIiEiUgoSIiEQpSIiISJSChIiIRP1/FSQ0dhST6MoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.officePrice,data.salesSum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "trained-devices",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_X = data.officePrice\n",
    "data_y = data.salesSum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "olympic-emperor",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0      12.235\n",
       " 1      12.290\n",
       " 2      12.940\n",
       " 3      13.480\n",
       " 4       3.870\n",
       "         ...  \n",
       " 187    22.170\n",
       " 188         0\n",
       " 189    23.130\n",
       " 190    10.035\n",
       " 191         0\n",
       " Name: officePrice, Length: 192, dtype: object,\n",
       " 0      538680\n",
       " 1      295857\n",
       " 2      417332\n",
       " 3      343418\n",
       " 4      119255\n",
       "         ...  \n",
       " 187        17\n",
       " 188       370\n",
       " 189       427\n",
       " 190       432\n",
       " 191         5\n",
       " Name: salesSum, Length: 192, dtype: int64)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_X,data_y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "trying-demographic",
   "metadata": {},
   "outputs": [],
   "source": [
    "model=LinearRegression()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "christian-compound",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression()"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(data_X.values.reshape(-1,1),data_y.values.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "broadband-incidence",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[586.01131608]]\n",
      "[38025.74072828]\n",
      "{'copy_X': True, 'fit_intercept': True, 'n_jobs': None, 'normalize': False, 'positive': False}\n",
      "0.0073578783944698856\n"
     ]
    }
   ],
   "source": [
    "print(model.coef_)      #如果y=0.1x+0.3   则此行输出的结果为0.1\n",
    "print(model.intercept_)             #此行输出的结果为0.3\n",
    "print(model.get_params())       #模型定义时定义的参数，如果没有定义则返回默认值\n",
    "print(model.score(data_X.values.reshape(-1,1),data_y.values.reshape(-1,1)))   #给训练模型打分，注意用在LinearR中使用R^2 conefficient of determination打分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "auburn-switch",
   "metadata": {},
   "outputs": [],
   "source": [
    "mu =np.mean(data_X.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "unsigned-scroll",
   "metadata": {},
   "outputs": [],
   "source": [
    "sigma =np.std(data_X.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "boolean-interview",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15.966484375000006, 11.437763829369034)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mu,sigma"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "unable-trademark",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'norm' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-26-1c3946c8b2c2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mn\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbins\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpatches\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata_X\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnum_bins\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdensity\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0malpha\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.75\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;31m#直方图函数，x为x轴的值，normed=1表示为概率密度，即和为一，绿色方块，色深参数0.5.返回n个概率，直方块左边线的x值，及各个方块对象\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnorm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpdf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbins\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmu\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#拟合一条最佳正态分布曲线y\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgrid\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'norm' is not defined"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAP20lEQVR4nO3df6zdd13H8efLlhUiskl3IaYttGQ1pPhjxFpYBINbwE6RkrhJp8b+saQQWYJBosXEORpInH8wSZjRhi3ORuyW4fRGayZhi7+CpXdsZnSz8W6MrBXZ3Q+mU7dR9/aP8y0cj2e73/ae29vz6fORNPf7/Xw/59z3p/32dT75nvP9nFQVkqR2fddKFyBJWl4GvSQ1zqCXpMYZ9JLUOINekhq3eqULGHXhhRfWxo0bV7oMSZoq99xzz+NVNTPu2FkX9Bs3bmRubm6ly5CkqZLkay92zEs3ktQ4g16SGmfQS1LjDHpJapxBL0mNM+glqXEGvSQ1zqCXpMYZ9JLUuLPuzlgtn537vtir34HdlyxzJZLOJGf0ktQ4g16SGmfQS1LjDHpJapxBL0mNM+glqXEGvSQ1zqCXpMYZ9JLUOO+MPcO8O1XSmeaMXpIaZ9BLUuMMeklqnEEvSY0z6CWpcQa9JDXOoJekxhn0ktS4Xk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x8aGNdLmPrzcVQrQT9umYb/t9TClHttVX292/434LUrWcxSdSucvhk4RCNj6y5v3Ac8BnweeAj4ZlWd6LpM63n5u8CvAS90+2tpY1wweDH+6yT3dEuxQCPn47CzYgkEnZqqqiRT+7nYJK8EPgf8SlX9+2CCODDNY+vuEbk4yQXAHcAbV7aipUvybuCxqronyTtWuJzl8LaqOp7kNcDnk/zz8MFpPh+HtTKjPxeWWvhGku8D6H4+tsL1nJYkL2MQ8n9cVX/aNTcxtpOq6pvA3cAlwAXdsiAwnefljwHvSfIIg0uilwKfYvrHBUBVHe9+PsbgxXkbjZ2P0E7Q91mmYdoNLzOxC/jzFazltHTXdm8CHqyqTw4damFsM91MniSvAN7J4D2IuxksCwJTOLaq+mhVra+qjQz+X91VVb/AlI8LIMl3J/mek9vAu4Cv0MD5OKqZO2OT/BSDa4knl2n4xMpWdPqS/AnwDgbLpX4D+C3gz4DbgNcBXwN+rqpG37A9qyV5G/B3wP1853rvbzC4Tj/tY/shBm/crWIwgbqtqvYmeQODmfCrgXuBX6yq51au0tPXXbr5SFW9u4VxdWO4o9tdDXy2qj6RZC1Tfj6OaiboJUnjtXLpRpL0Igx6SWqcQS9JjTPoJalxBr0kNc6gl6TGGfSS1Lj/BZC4m3GiiaeXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "num_bins = 30 #直方图柱子的数量 \n",
    "n, bins, patches = plt.hist(data_X.values, num_bins,density=1, alpha=0.75) \n",
    "#直方图函数，x为x轴的值，normed=1表示为概率密度，即和为一，绿色方块，色深参数0.5.返回n个概率，直方块左边线的x值，及各个方块对象 \n",
    "y = norm.pdf(bins, mu, sigma)#拟合一条最佳正态分布曲线y \n",
    " \n",
    "plt.grid(True)\n",
    "plt.plot(bins, y, 'r--') #绘制y的曲线 \n",
    "plt.xlabel('values') #绘制x轴 \n",
    "plt.ylabel('Probability') #绘制y轴 \n",
    "plt.title('Histogram : $\\mu$=' + str(round(mu,2)) + ' $\\sigma=$'+str(round(sigma,2)))  #中文标题 u'xxx' \n",
    "#plt.subplots_adjust(left=0.15)#左边距 \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "subsequent-fifty",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
